<template>
  <el-card>
    <el-tabs v-if="show" v-model="activeName">
      <el-tab-pane  label="微信配置" name="wx">
        <wx :data="data.wechatData"></wx>
      </el-tab-pane>
      <el-tab-pane  label="支付宝配置" name="alipay">
        <alipay :data="data.alipayData"></alipay>
      </el-tab-pane>
    </el-tabs>
  </el-card>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import Alipay from '@/views/wx/payConfig/alipay.vue'
import wx from '@/views/wx/payConfig/wx.vue'
import { getConfigApi } from '@/api/wx/payConfig'
const data = ref({
  alipayData: {},
  wechatData: {}
})
const activeName = ref('wx')
const show = ref(false)
function getConfig() {
  show.value = false
  getConfigApi().then((res) => {
    show.value = true
    res.data.forEach((res) => {
      if (res.channelId === 'alipay') {
        data.value.alipayData = res
        if (data.value.alipayData.params === null) {
          data.value.alipayData.params = {}
        }
        console.log(data.value.alipayData.params)
        return
      }
      data.value.wechatData = res
    })
  })
}
getConfig()
</script>
